<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return['params']=array();
$return['status']=$this->order_status;
$return['paytype']=get_pay_types();
$return['ispay']=array('0'=>'未支付','1'=>'已支付');
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'isclear'=>intval($_RQ['isclear']),'ispay'=>1);
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;	
    $orderby='createtime desc';
	$total='';
	if(!empty($_RQ['orderid'])){
		$params['orderid']=trim($_RQ['orderid']);
		$return['params']['orderid']=$_RQ['orderid'];
	}
	//创建时间
	if($_RQ['createtime']){
		$time_range=cfc('tools')->base64_decode($_RQ['createtime'],$_SESSION['base_key_str']);
		$time_range=json_decode($time_range,true);
		$params['createtime between']=array($time_range['tstart'],$time_range['tend']);
		$return['params']['createtime']=$time_range;
	}
	$return['list']=pdo_getslice('jy_mapfuwu_order',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	$setting=$this->plugin_setting('setting');
	$fee_rate=$setting['fee_rate'];
	foreach($return['list'] as &$gv){
		$gv['koufee']=$gv['price']*$fee_rate/100;
	}
	$htmls=array(
		'type'=>'list',
		'export'=>'export',
		'tabs'=>array(
			array('op'=>'list','title'=>'待结算订单/商品'),
		),
		'list'=>array('data'=>'list','tip'=>'[<red>温馨提示</red>]：基本设置--可提现金额是否扣除平台佣金','delall'=>false,'del_one'=>false,'edit'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单号','type'=>'string'),
			array('name'=>'price','title'=>'订单金额','type'=>'string'),
			array('name'=>'koufee','title'=>'平台佣金','type'=>'string'),
			array('name'=>'createtime','title'=>'下单时间','type'=>'time'),		
		)),
		'search'=>array(
			array('name'=>'ordersn','width'=>15,'title'=>'订单号','type'=>'string'),
			array('name'=>'createtime','width'=>15,'title'=>'下单时间','type'=>'time_range'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='export'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'isclear'=>intval($_RQ['isclear']),'ispay'=>1);
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;	
    $orderby='createtime desc';
	$total='';
	if(!empty($_RQ['orderid'])){
		$params['orderid']=trim($_RQ['orderid']);
		$return['params']['orderid']=$_RQ['orderid'];
	}
	//创建时间
	if($_RQ['createtime']){
		$time_range=cfc('tools')->base64_decode($_RQ['createtime'],$_SESSION['base_key_str']);
		$time_range=json_decode($time_range,true);
		$params['createtime between']=array($time_range['tstart'],$time_range['tend']);
		$return['params']['createtime']=$time_range;
	}
	$list=pdo_getall('jy_mapfuwu_order',$params);
	$setting=$this->plugin_setting('setting');
	$fee_rate=$setting['fee_rate'];
	foreach($list as &$gv){
		$gv['koufee']=$gv['price']*$fee_rate/100;
		$gv['createtime']=date('Y-m-d',$gv['createtime']);
	}
	$header=array(
		'ordersn'=>'订单号',
		'price'=>'订单金额',
		'koufee'=>'平台佣金',	
		'createtime'=>'下单时间',
	);
	cfc('tools')->export2excel($header,$list,'订单');
}

?>